package org.pas.fb2.tag;

public abstract class Textual extends Tag {

    private final StringBuilder text = new StringBuilder();

    public Textual(Tag parent) {
        super(parent);
    }

    @Override
    public Tag onChild(String name) {
        if (StyleTag.NAME.equals(name)) {
            return new StyleTag(this);
        } else if (EmphasisTag.NAME.equals(name)) {
            return new EmphasisTag(this);
        } else if (StrongTag.NAME.equals(name)) {
            return new StrongTag(this);
        } else if (SupTag.NAME.equals(name)) {
            return new SupTag(this);
        } else if (SubTag.NAME.equals(name)) {
            return new SubTag(this);
        } else if (AnchorTag.NAME.equals(name)) {
            return new AnchorTag(this);
        }
        return super.onChild(name);
    }

    @Override
    public void onChars(char ch[], int start, int length) {
        text.append(ch, start, length);
    }

    public CharSequence getText() {
        return text;
    }
    
}
